<template>
  <div class="order">
    <!-- 我的订单头部 -->
    <div class="order-header">
      <div class="order-header-content">
        <p>
          <i
            class="el-icon-s-order"
            style="font-size: 30px; color: #ff6700"
          ></i>
          我的订单
        </p>
      </div>
    </div>

    <!-- 我的订单主要内容 -->

    <div class="order-content" v-if="data.length > 0">
      <div class="content" v-for="item in data" :key="item.id">
        <ul>
          <!-- 我的订单表头 -->
          <li class="order-info">
            <div class="order-id">
              订单编号:
              {{ item.order_id }}
            </div>
            <div class="order-time">
              订单时间: {{ item.order_time | dateFormat }}
            </div>
          </li>
          <li class="header">
            <div class="pro-img"></div>
            <div class="pro-name">商品名称</div>
            <div class="pro-price">单价</div>
            <div class="pro-num">数量</div>
            <div class="pro-total">小计</div>
          </li>

          <!-- 订单列表 -->
          <!-- v-for="(product,i) in item" :key="i" -->
          <li class="product-list">
            <div class="pro-img">
              <router-link :to="{ path: '/details' }">
                <img :src="'http://39.100.7.70:81/' + product_picture" />
              </router-link>
            </div>
            <div class="pro-name">
              <!-- :to="{ path: '/goods/details', query: {productID:product.product_id} }" -->

              <router-link to="">{{ product_name }}</router-link>
            </div>

            <div class="pro-price">{{ product_price }}元</div>

            <div class="pro-num">{{ product_num }}</div>

            <div class="pro-total pro-total-in">
              {{ product_price * product_num }}元
            </div>
          </li>
        </ul>
        <div class="order-bar">
          <div class="order-bar-left">
            <span class="order-total">
              共
              <span class="order-total-num">2</span> 件商品
            </span>
          </div>
          <div class="order-bar-right">
            <span>
              <span class="total-price-title">合计：</span>
              <span class="total-price"
                >{{ item.product_num * item.product_price }}元</span
              >
            </span>
          </div>
        </div>
      </div>
      <div style="margin-top: -40px"></div>
    </div>

    <!-- 订单为空的时候显示的内容 -->
    <div v-else class="order-empty">
      <div class="empty">
        <h2>您的订单还是空的！</h2>
        <p>快去购物吧！</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      data: [
        {
          id: 3777,
          order_id: 30641618817555504,
          order_time: 1618817555506,
          product_id: 3,
          product_name: "小米CC9 Pro",
          product_num: 1,
          product_picture: "public/imgs/phone/Mi-CC9.png",
          product_price: 2599,
          user_id: 3064,
        },
        {
          id: 3768,
          order_id: 30641618811613224,
          order_time: 1618811613223,
          product_id: 9,
          product_name: "小米电视4A 32英寸",
          product_num: 1,
          product_picture: "public/imgs/appliance/MiTv-4A-32.png",
          product_price: 799,
          user_id: 3064,
        },
      ],
    };
  },
  mounted() {},
  methods: {},
  computed: {},
  watch: {},
};
</script>

<style lang="scss" scoped>
.order {
  background-color: #f5f5f5;
  padding-bottom: 20px;
  .order-header {
    height: 64px;
    border-bottom: 2px solid #ff6700;
    background-color: #fff;
    margin-bottom: 20px;
    .order-header-content {
      width: 1225px;
      margin: 0 auto;
    }
    p {
      font-size: 28px;
      line-height: 58px;
      float: left;
      font-weight: normal;
      color: #424242;
    }
  }
  //内容
  .content {
    width: 1225px;
    margin: 0 auto;
    background-color: #fff;
    margin-bottom: 50px;
    ul {
      background-color: #fff;
      color: #424242;
      line-height: 85px;
      .order-info {
        height: 60px;
        line-height: 60px;
        padding: 0 26px;
        color: #424242;
        border-bottom: 1px solid #ff6700;
        .order-id {
          float: left;
          color: #ff6700;
        }
        .order-time {
          float: right;
        }
      }
      .header {
        height: 85px;
        padding-right: 26px;
        color: #424242;
      }
      .product-list {
        height: 85px;
        padding: 15px 26px 15px 0;
        border-top: 1px solid #e0e0e0;
      }
      .pro-img {
        float: left;
        height: 85px;
        width: 120px;
        padding-left: 80px;
        img {
          height: 80px;
          width: 80px;
        }
      }
      .pro-name {
        float: left;
        width: 380px;
        a {
          color: #424242;
        }
        a:hover {
          color: #ff6700;
        }
      }
      .pro-price {
        float: left;
        width: 160px;
        padding-right: 18px;
        text-align: center;
      }
      .pro-num {
        float: left;
        width: 190px;
        text-align: center;
      }
      .pro-total {
        float: left;
        width: 160px;
        padding-right: 81px;
        text-align: right;
      }
      .pro-total-in {
        color: #ff6700;
      }
    }
  }
  .order-bar {
    width: 1185px;
    padding: 0 20px;
    border-top: 1px solid #ff6700;
    height: 50px;
    line-height: 50px;
    background-color: #fff;
    .order-bar-left {
      float: left;
      .order-total {
        color: #757575;
      }
      .order-total-num {
        color: #ff6700;
      }
    }
    .order-bar-right {
      float: right;
      .total-price-title {
        color: #ff6700;
        font-size: 14px;
      }
      .total-price {
        color: #ff6700;
        font-size: 30px;
      }
    }
  }

  .order-empty {
    width: 1225px;
    margin: 0 auto;
    .empty {
      height: 300px;
      padding: 0 0 130px 558px;
      margin: 65px 0 0;
      background: url(../assets/imgs/cart-empty.png) no-repeat 124px 0;
      color: #b0b0b0;
      overflow: hidden;
      h2 {
        margin: 70px 0 15px;
        font-size: 36px;
      }
      p {
        margin: 0 0 20px;
        font-size: 20px;
      }
    }
  }
}
</style>